feat(settlement): add batch_receive_payment for multi-developer crediting - #369
Merged
greatest0fallt1me merged 2 commits intoMay 27, 2026
Conversation
…ting Closes CalloraOrg#341 - Add MAX_BATCH_SIZE = 50 constant (aligns with vault batch_deduct and revenue pool batch_distribute) - Add batch_receive_payment(caller, items: Vec<(Address, i128)>) that: - Requires vault or admin caller via require_authorized_caller - Rejects empty batches and batches exceeding MAX_BATCH_SIZE - Validates all amounts > 0 before any state write (atomicity) - Credits each developer balance with checked_add - Emits balance_credited event per leg - Add 9 tests covering: multi-dev credits, balance accumulation, admin caller, empty batch, oversized batch, zero/negative amounts, unauthorized caller, single item, and exact MAX_BATCH_SIZE
|
@Richardkingz2019 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #341
Adds
batch_receive_payment(caller, items: Vec<(Address, i128)>)toCalloraSettlement, enabling atomic multi-developer crediting in a single call — mirroring the vault'sbatch_deductand the revenue pool'sbatch_distributepatterns.Changes
contracts/settlement/src/lib.rsMAX_BATCH_SIZE = 50constant (aligned with vault and revenue pool)batch_receive_payment(caller, items):require_authorized_caller(vault or admin)MAX_BATCH_SIZE> 0before any state write (full atomicity)checked_add(overflow-safe)balance_creditedevent per legcontracts/settlement/src/test.rsAdded 9 tests:
test_batch_receive_payment_credits_multiple_developerstest_batch_receive_payment_accumulates_existing_balancetest_batch_receive_payment_admin_caller_allowedtest_batch_receive_payment_rejects_empty_batchtest_batch_receive_payment_rejects_oversized_batchtest_batch_receive_payment_rejects_zero_amounttest_batch_receive_payment_rejects_negative_amounttest_batch_receive_payment_unauthorized_caller_rejectedtest_batch_receive_payment_single_itemtest_batch_receive_payment_max_batch_size_acceptedTesting
All 64 tests pass (
cargo test -p callora-settlement), including all 9 new batch tests.